<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Gregwar\Captcha\CaptchaBuilder;
use Session;

class CatpchaController extends Controller
{
    /**
     * 验证码
     */
    public function cat()
    {

        $builder = new CaptchaBuilder;

        //可以设置图片宽高及字体
        $builder->build($width = 200, $height = 80, $font = null);
        //获取验证码的内容
        $phrase = $builder->getPhrase();

        Session::flash('milkcaptcha', $phrase);
        //生成图片
       //header('Content-Type: image/jpeg');
        header("Cache-Control: no-cache, must-revalidate");
        //$builder->output();
        return response($builder->output())->header('Content-Type', 'image/jpeg');
    }
}